
use std::path::{PathBuf, Path};
use rocket::fs::{NamedFile, relative};

use rocket::response::content;
use rocket::serde::de::IntoDeserializer;


#[macro_use]
extern crate rocket;

#[get("/")]
pub async fn index() -> Option<NamedFile> {
    NamedFile::open("www/index.html").await.ok()
}

#[get("/<path..>")]
pub async fn json(path: PathBuf) -> Option<NamedFile> {
    println!("{:?}", path);
    let path = Path::new(relative!("www")).join(path);
    NamedFile::open(path).await.ok()
}



#[launch]
fn rocket() -> _ {
    rocket::build()
    .mount("/", routes![index])
    .mount("/json", routes![json])
}
